package org.platform.core.system.heartbeat;

import com.mc.mic.core.log.bus.BusLogPusher;
import com.mc.mic.core.log.frame.LogBo;
import org.platform.constant.LogType;
import org.platform.mo.bussmo.log.HeartbeatPpackageBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 系统统一发送心跳包
 *
 * @author FengJie
 * @date 2018/7/5
 */
@Component
public class HeartbeatJob {
    @Autowired
    private BusLogPusher mqLog;

    @PostConstruct
    public void init() {
        //todo 后面需要统一全部使用线程池
        new Thread(() -> {
            while (true) {
                mqLog.log(new LogBo<>(LogType.HEARTBEAT, new HeartbeatPpackageBO("心跳内容")));
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }).start();
    }
}
